package de.ars.client.paintSystems;

import de.ars.client.animator.Point;

public class ClassicLayout
{
    private int width;
    private int height;

    private static final float PROPERTION_NORMAL_TAB_LEFT_WINDOW = 0.13f;
    private static final float PROPERTION_NORMAL_TAB_TOP_WINDOW = 0.25f;
    private static final float PROPERTION_NORMAL_WINDOW_WIDTH = 0.73333333f;
    private static final float PROPERTION_NORMAL_WINDOW_HEIGHT = 0.6f;
    private static final float PROPERTION_NORMAL_TAB_INWINDOW_PORTRAIT = 0.05f;

    private static final float PROPERTION_DETAIL_TAB_TOP_WINDOW = 0.2f;
    private static final float PROPERTION_DETAIL_WINDOW_HEIGHT = 0.85f;
    private static final float PROPERTION_DETAIL_TAB_LEFT_PORTRAIT = 0.065f;
    private static final float PROPERTION_DETAIL_TAB_TOP_PORTRAIT = 0.05f;

    private static final float PROPERTION_WINDOW_SHRINK = 0.83f;
    private static final float PROPERTION_WINDOW_WINDOW_GAP = 0.065f;
    
    private static final float PROPERTION_OPTION_TAB_LEFT = 0.3f;
    private static final float PROPERTION_OPTION_TAB_TOP = 0.4f;
    private static final float PROPERTION_OPTION_WINDOW_HEIGHT = 0.55f;
    private static final float PROPERTION_BOTTOMBAR = 0.05f;
    
    private static final float PROPERTION_EDIT_WINDOW_HEIGHT = 0.28f;
    
    private static final float PROPERTION_ImportPictureManager_HEIGHT = 0.23f;
    
    private static final float PROPERTION_ADD_PERSON_TEXT_TAB_TOP = 0.7f;
    
    private static final float PROPERTION_SYNC_WITH_CSV_TEXT_TAB_TOP = 0.7f;

    private Point position[];
    private Point windowSize[];
    private Point portraitPos[];
    private Point textPos[];

    private Point detailPos;
    private Point detailSize;
    private Point detailPortraitPos;
    private Point detailTextPos;
    //Options
    private Point optionPos;
    private Point optionSize;    
    private Point optionClosePos;
    private Point optionCloseSize;
    private Point optionTextPos;
    private Point optionCloseTextPos;
    //Edit
    private Point editPos;
    private Point editSize;
    private Point editClosePos;
    private Point editCloseSize;
    private Point editTextPos;
    private Point editCloseTextPos;
    //Add Person
    private Point addPersonPos;
    private Point addPersonSize;
    private Point addPersonTextPos;
    private Point addPersonClosePos;
    private Point addPersonCloseSize;
    private Point addPersonCloseTextPos;
    //Add Option to Person
    private Point addOptionToPersonPos;
    private Point addOptionToPersonSize;
    private Point addOptionToPersonTextPos;
    private Point addOptionToPersonClosePos;
    private Point addOptionToPersonCloseSize;
    private Point addOptionToPersonCloseTextPos;
    //Sync with CSV
    private Point syncWithCsvPos;
    private Point syncWithCsvSize;
    private Point syncWithCsvTextPos;
    private Point syncWithCsvClosePos;
    private Point syncWithCsvCloseSize;
    private Point syncWithCsvCloseTextPos;
    //PictureManager
    private Point PicManagerPos;
    private Point PicManagerSize;    
    private Point PicManagerClosePos;
    private Point PicManagerCloseSize;
    private Point PicManagerTextPos;
    private Point PicManagerCloseTextPos;

    public ClassicLayout( int width, int height )
    {
        this.width = width;
        this.height = height;

        position = new Point[5];
        windowSize = new Point[5];
        portraitPos = new Point[5];
        textPos = new Point[5];

        calcLayout();
    }

    private void calcLayout()
    {
        windowSize[2] = new Point( this.width * PROPERTION_NORMAL_WINDOW_WIDTH, this.height
                * PROPERTION_NORMAL_WINDOW_HEIGHT );
        position[2] = new Point( this.width * PROPERTION_NORMAL_TAB_LEFT_WINDOW, this.height
                * PROPERTION_NORMAL_TAB_TOP_WINDOW );

        windowSize[1] = new Point( windowSize[2].getX() * PROPERTION_WINDOW_SHRINK, windowSize[2].getY()
                * PROPERTION_WINDOW_SHRINK );
        position[1] = new Point( position[2].getX() - windowSize[1].getX() - this.width * PROPERTION_WINDOW_WINDOW_GAP,
                position[2].getY() + windowSize[2].getY() / 2 - windowSize[1].getY() / 2 );

        windowSize[0] = new Point( windowSize[1] );
        position[0] = new Point( position[1].getX() - windowSize[1].getX(), position[1].getY() );

        windowSize[3] = new Point( windowSize[1] );
        position[3] = new Point( position[2].getX() + windowSize[2].getX() + this.width * PROPERTION_WINDOW_WINDOW_GAP,
                position[1].getY() );

        windowSize[4] = new Point( windowSize[1] );
        position[4] = new Point( position[3].getX() + windowSize[3].getX(), position[3].getY() );

        detailPos = new Point( 0, this.height * PROPERTION_DETAIL_TAB_TOP_WINDOW );
        detailSize = new Point( this.width, this.height * PROPERTION_DETAIL_WINDOW_HEIGHT );
        //Options
        this.optionPos = new Point(this.width * PROPERTION_OPTION_TAB_LEFT,
        		this.height * PROPERTION_OPTION_TAB_TOP);
        this.optionSize = new Point(this.width - (this.width * PROPERTION_OPTION_TAB_LEFT), 
        		this.height * PROPERTION_OPTION_WINDOW_HEIGHT);
        this.optionClosePos =  new Point(this.width * PROPERTION_OPTION_TAB_LEFT,
        		this.height - (this.height * PROPERTION_BOTTOMBAR));
        this.optionCloseSize = new Point(this.width - (this.width * PROPERTION_OPTION_TAB_LEFT), 
        		this.height * PROPERTION_OPTION_WINDOW_HEIGHT);
        this.optionTextPos = new Point(this.width * (PROPERTION_OPTION_TAB_LEFT + PROPERTION_DETAIL_TAB_LEFT_PORTRAIT),
        		this.height * (PROPERTION_OPTION_TAB_TOP + PROPERTION_DETAIL_TAB_TOP_PORTRAIT));
        this.optionCloseTextPos = new Point(this.width * (PROPERTION_OPTION_TAB_LEFT + PROPERTION_DETAIL_TAB_LEFT_PORTRAIT),
        		this.height - (this.height * (PROPERTION_BOTTOMBAR-PROPERTION_DETAIL_TAB_TOP_PORTRAIT)));
    
        //Edit
        this.editPos = new Point(0,
        		this.height - (this.height * PROPERTION_EDIT_WINDOW_HEIGHT));
        this.editSize = new Point(this.width, this.editPos.getY());
        this.editClosePos = new Point(0, this.height - (this.height * PROPERTION_BOTTOMBAR));
        this.editCloseSize = new Point(this.width, this.editPos.getY());
        this.editTextPos = new Point(this.width * (PROPERTION_DETAIL_TAB_LEFT_PORTRAIT), 
        		this.height - (this.height * (PROPERTION_DETAIL_TAB_TOP_WINDOW + PROPERTION_DETAIL_TAB_TOP_PORTRAIT)));
        this.editCloseTextPos = new Point(this.width * (PROPERTION_DETAIL_TAB_LEFT_PORTRAIT),
        		this.height - (this.height * (PROPERTION_BOTTOMBAR - PROPERTION_DETAIL_TAB_TOP_WINDOW)));
    
        //Add Person
        this.addPersonPos = new Point(0,
        		this.height * PROPERTION_DETAIL_TAB_TOP_WINDOW);
        this.addPersonSize = new Point(this.width, this.height * PROPERTION_DETAIL_WINDOW_HEIGHT);
        this.addPersonClosePos = this.editClosePos;
        this.addPersonCloseSize = new Point(this.width, this.addPersonSize.getY());
        this.addPersonTextPos = new Point(this.editTextPos.getX(),
        		this.height - (this.height * PROPERTION_ADD_PERSON_TEXT_TAB_TOP));
        this.addPersonCloseTextPos = this.editCloseTextPos;
        
//        //Add Option to person
//        this.addOptionToPersonPos = this.editPos;
//        this.addOptionToPersonSize = this.editSize;
//        this.addOptionToPersonTextPos = this.editTextPos;
//        this.addOptionToPersonClosePos = this.editClosePos;
//        this.addOptionToPersonCloseSize = this.editCloseSize;
//        this.addOptionToPersonCloseTextPos = this.editCloseTextPos;

        this.addOptionToPersonPos = this.addPersonPos;
        this.addOptionToPersonSize = this.addPersonSize;
        this.addOptionToPersonTextPos = this.addPersonTextPos;
        this.addOptionToPersonClosePos = this.addPersonClosePos;
        this.addOptionToPersonCloseSize = this.addPersonCloseSize;
        this.addOptionToPersonCloseTextPos = this.addPersonCloseTextPos;
        
        //Sync with CSV
        this.syncWithCsvPos = new Point(0, this.height * PROPERTION_DETAIL_TAB_TOP_WINDOW);
        this.syncWithCsvSize = new Point(this.width, this.height * PROPERTION_DETAIL_WINDOW_HEIGHT);
        this.syncWithCsvClosePos = this.editClosePos;
        this.syncWithCsvCloseSize = new Point(this.width, this.syncWithCsvSize.getY());
        this.syncWithCsvTextPos = new Point(this.editTextPos.getX(),
        		this.height - (this.height * PROPERTION_SYNC_WITH_CSV_TEXT_TAB_TOP));
        this.syncWithCsvCloseTextPos = this.editCloseTextPos;

        //PictureManager
        this.PicManagerPos = new Point(0, this.height * PROPERTION_DETAIL_TAB_TOP_WINDOW);
        this.PicManagerSize = new Point(this.width, this.height * PROPERTION_ImportPictureManager_HEIGHT);
        this.PicManagerClosePos = this.editClosePos;
        this.PicManagerCloseSize = new Point(this.width, this.PicManagerSize.getY());
    }

    public void recalcImagePos( int imgWidth, int imgHeight )
    {
        for( int i = 0; i < 5; i++ )
        {
            portraitPos[i] = new Point(  width * (PROPERTION_NORMAL_WINDOW_WIDTH /2), height
                    * PROPERTION_NORMAL_TAB_INWINDOW_PORTRAIT );
            textPos[i] = new Point( windowSize[i].getX() * 0.1f, this.height * PROPERTION_NORMAL_TAB_INWINDOW_PORTRAIT
                    + imgHeight );
        }

        detailPortraitPos = new Point( width * (PROPERTION_DETAIL_TAB_LEFT_PORTRAIT*3), height * PROPERTION_DETAIL_TAB_TOP_PORTRAIT );
        
        detailTextPos = new Point( width * PROPERTION_DETAIL_TAB_LEFT_PORTRAIT, height
                * PROPERTION_DETAIL_TAB_TOP_PORTRAIT + imgHeight );
    }

    public int getIndexOfRelativePos( int relativPos )
    {
        return relativPos + 2;
    }
    /*	Edit	*/
    public Point getEditPos()
    {
    	return this.editPos;
    }
    
    public Point getEditSize()
    {
    	return this.editSize;
    }
    
    public Point getEditClosePos()
    {
    	return this.editClosePos;
    }

    public Point getEditCloseSize()
    {
    	return this.editCloseSize;
    }
    
    public Point getEditTextPos()
    {
    	return this.editTextPos;
    }
    
    public Point getEditCloseTextPos()
    {
    	return this.editCloseTextPos;
    }
    /*	Edit	ENDE	*/
    /*	Option	*/
    public Point getOptionPos()
    {
    	return this.optionPos;
    }
    
    public Point getOptionTextPos()
    {
    	return this.optionTextPos;
    }
    
    public Point getOptionClosePos()
    {
    	return this.optionClosePos;
    }
    
    public Point getOptionCloseSize()
    {
    	return this.optionCloseSize;
    }
    
    public Point getOptionCloseTextPos()
    {
    	return this.optionCloseTextPos;
    }
    
    public Point getOptionSize()
    {
    	return this.optionSize;
    }
    /*	Option	ENDE	*/
    /*	Add Person	*/
    public Point getAddPersonPos()
    {
    	return this.addPersonPos;
    }
    
    public Point getAddPersonSize()
    {
    	return this.addPersonSize;
    }
    
    public Point getAddPersonTextPos()
    {
    	return this.addPersonTextPos;
    }
    
    public Point getAddPersonClosePos()
    {
    	return this.addPersonClosePos;
    }
    
    public Point getAddPersonCloseSize()
    {
    	return this.addPersonCloseSize;
    }
    public Point getPicManagerClosePos()
    {
    	return this.PicManagerClosePos;
    }
    
    public Point getPicManagerCloseSize()
    {
    	return this.PicManagerCloseSize;
    }
    
    public Point getAddPersonCloseTextPos()
    {
    	return this.addPersonCloseTextPos;
    }
    /*	Add Person	ENDE	*/
    /*	Add Person Option	*/
    public Point getAddPersonOptionPos()
    {
    	return this.addOptionToPersonPos;
    }
    
    public Point getAddPersonOptionSize()
    {
    	return this.addOptionToPersonSize;
    }
    
    public Point getAddPersonOptionTextPos()
    {
    	return this.addOptionToPersonTextPos;
    }
    
    public Point getAddPersonOptionClosePos()
    {
    	return this.addOptionToPersonClosePos;
    }
    
    public Point getAddPersonOptionCloseSize()
    {
    	return this.addOptionToPersonCloseSize;
    }
    
    public Point getAddPersonOptionCloseTextPos()
    {
    	return this.addOptionToPersonCloseTextPos;
    }
    /*	Add Person Option	ENDE	*/
    /*	Sync with CSV	*/
    public Point getSyncWithCsvPos()
    {
    	return this.syncWithCsvPos;
    }
    
    public Point getSyncWithCsvSize()
    {
    	return this.syncWithCsvSize;
    }
    
    public Point getSyncWithCsvTextPos()
    {
    	return this.syncWithCsvTextPos;
    }
    
    public Point getSyncWithCsvClosePos()
    {
    	return this.syncWithCsvClosePos;
    }
    
    public Point getSyncWithCsvCloseSize()
    {
    	return this.syncWithCsvCloseSize;
    }
    
    public Point getSyncWithCsvCloseTextPos()
    {
    	return this.syncWithCsvCloseTextPos;
    }
    /*	Sync with CSV	ENDE	*/
    
    public Point getPos( int relativPos )
    {
        return position[getIndexOfRelativePos( relativPos )];
    }

    public Point getSize( int relativPos )
    {
        return windowSize[getIndexOfRelativePos( relativPos )];
    }

    public Point getPortraitPos( int relativPos )
    {
        return portraitPos[getIndexOfRelativePos( relativPos )];
    }

    public Point getTextPos( int relativPos )
    {
        return textPos[getIndexOfRelativePos( relativPos )];
    }

    public Point getDetailPos()
    {
        return this.detailPos;
    }

    public Point getDetailPortraitPos()
    {
        return this.detailPortraitPos;
    }

    public Point getDetailSize()
    {
        return this.detailSize;
    }

    public Point getDetailTextPos()
    {
        return this.detailTextPos;
    }
}
